unit Option;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TfrmOption = class(TForm)
    GroupBox1: TGroupBox;
    chkOffline: TCheckBox;
    pnlOffline: TPanel;
    btnOfflineColor: TButton;
    btn1: TButton;
    btn2: TButton;
    chkBeChangedMoney: TCheckBox;
    pnlBeChangedMoney: TPanel;
    btnBeChangedMoney: TButton;
    chkChangeMoney: TCheckBox;
    pnlChangeMoney: TPanel;
    btnChangeMoney: TButton;
    btnDefault: TButton;
    dlgColor: TColorDialog;
    procedure btnOfflineColorClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure btnDefaultClick(Sender: TObject);
    procedure btn1Click(Sender: TObject);
    procedure btnBeChangedMoneyClick(Sender: TObject);
    procedure btnChangeMoneyClick(Sender: TObject);
  private
    { Private declarations }
    procedure LoadOption;
    procedure SaveOption;
  public
    { Public declarations }

  end;

var
  frmOption: TfrmOption;

implementation

uses uOptionHandle, GlobalObject;

{$R *.dfm}

procedure TfrmOption.btn1Click(Sender: TObject);
begin
  SaveOption;
end;

procedure TfrmOption.btnBeChangedMoneyClick(Sender: TObject);
begin
  if dlgColor.Execute then
  begin
    pnlBeChangedMoney.Color := dlgColor.Color;
  end;
end;

procedure TfrmOption.btnChangeMoneyClick(Sender: TObject);
begin
  if dlgColor.Execute then
  begin
    pnlChangeMoney.Color := dlgColor.Color;
  end;

end;

procedure TfrmOption.btnDefaultClick(Sender: TObject);
begin
  gOptionHandle.LoadDefault;
  LoadOption;
end;

procedure TfrmOption.btnOfflineColorClick(Sender: TObject);
begin
  if dlgColor.Execute then
  begin
    pnlOffline.Color := dlgColor.Color;
  end;
end;

procedure TfrmOption.FormActivate(Sender: TObject);
begin
  //
  LoadOption;
end;



procedure TfrmOption.LoadOption;
begin
  chkOffline.Checked := gOptionHandle.UsedOfflineTransColor;
  chkBeChangedMoney.Checked := gOptionHandle.UsedBeMoneyChangedColor;
  chkChangeMoney.Checked := gOptionHandle.UsedMoneyChangeColor;

  pnlOffline.Color := gOptionHandle.OfflineTransColor;
  pnlBeChangedMoney.Color := gOptionHandle.BeMoneyChangedColor;
  pnlChangeMoney.Color := gOptionHandle.MoneyChangeColor;

end;

procedure TfrmOption.SaveOption;
begin
  gOptionHandle.UsedOfflineTransColor := chkOffline.Checked;
  gOptionHandle.UsedMoneyChangeColor := chkChangeMoney.Checked;
  gOptionHandle.UsedBeMoneyChangedColor := chkBeChangedMoney.Checked;

  gOptionHandle.OfflineTransColor := pnlOffline.Color;
  gOptionHandle.BeMoneyChangedColor := pnlBeChangedMoney.Color;
  gOptionHandle.MoneyChangeColor := pnlChangeMoney.Color;

end;

end.
